﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;

namespace Xejen.Communication.Ftp
{
    /// <summary>
    /// 表示Ftp请求结果
    /// </summary>
    /// <creator>marc</creator>
    public class FtpResponse : Result
    {
        /// <summary>
        /// 服务器处理请求的状态码。
        /// </summary>
        public int StatusCode { get; set; }
        /// <summary>
        /// 提供有关状态码的描述信息。
        /// </summary>
        public string StatusDescription { get; set; }

        /// <inheritdoc cref="FtpResponse"/>
        public FtpResponse()
        {

        }

        /// <summary>
        /// 返回一个表示成功的<see cref="FtpResponse"/>对象
        /// </summary>
        /// <param name="statusCode"><inheritdoc cref="StatusCode" path="/summary"/></param>
        /// <param name="statusDescription"><inheritdoc cref="StatusDescription" path="/summary"/></param>
        public static FtpResponse Success(int statusCode, string statusDescription)
        {
            FtpResponse response = new FtpResponse();
            response.StatusCode = statusCode;
            response.StatusDescription = statusDescription;
            response.Code = SuccessCode;

            return response;
        }

        /// <summary>
        /// 返回一个表示失败的<see cref="FtpResponse"/>对象
        /// </summary>
        /// <param name="statusCode"><inheritdoc cref="StatusCode" path="/summary"/></param>
        /// <param name="statusDescription"><inheritdoc cref="StatusDescription" path="/summary"/></param>
        /// <param name="code"><inheritdoc cref="IResult.Code" path="/summary"/></param>
        /// <param name="exception"><inheritdoc cref="IResult.Exception" path="/summary"/></param>
        public static FtpResponse Fail(int statusCode, string statusDescription, int code, Exception exception = default)
        {
            return new FtpResponse
            {
                StatusCode = statusCode,
                StatusDescription = statusDescription,
                Code = code,
                Exception = exception,
            };
        }
    }
}
